<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <!-- 引入axios库 -->
    <script src="./node_modules/axios/dist/axios.js"></script>
    <script>
        // 配置全局baseURL，拼接起来
        axios.defaults.baseURL="https://apimusic.linweiqin.com";
        axios.get("/song/url",{
            params:{
                id:107// 把id以查询串的方式拼接在了url后面
            }
        }).then((res)=>{
                console.log(res);
            }).catch((err)=>console.log(err)).finally(function(){
                console.log("请求完成");
            })

    // 单个实例的配置
    let instance=axios.create({
        baseURL:"http://s.linweiqin.com"
    });
    // 把axios改成instance
    instance
      .post("/api/s/getIndexLoopimg", {
        username: "TT",
      })
      .then((res) => {
        console.log(res);
      })
      .catch((err) => console.log(err))
      .finally(function () {
        console.log("请求完成啦");
      });
        
    // 全局配置和单个实例配置互不影响
        



    </script>
</body>
</html>